package ggze.esp.dao.inter;

import ggze.esp.entity.FspNavigation;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface FspNavigationDao {

    @Insert("insert into FSP_NAVIGATION (${name0}) values ('${value0}')")
    int add(@Param("name0") String n, @Param("value0") String v);

    @Delete("delete from FSP_NAVIGATION where ${name1} = '${value1}'")
    int delete(@Param("name1") String n, @Param("value1") String v);

    @Update("update FSP_NAVIGATION set ${name2}='${value2}' where ${name4} = '${value4}'")
    int update(@Param("name2") String n, @Param("value2") String v, @Param("name4") String va, @Param("value4") String vas);

    @Select("select * from FSP_NAVIGATION")
    List<FspNavigation> allSelect();

    @Select("select * from FSP_NAVIGATION where ${name3} = '${value3}'")
    FspNavigation isSelect(@Param("name3") String n, @Param("value3") String v);

    @Select("select * from FSP_NAVIGATION where ${tjname} = '${tjva}' order by uuid limit ${begin},${end}")
    List<FspNavigation> paging(@Param("tjname") String tjname, @Param("tjva") String tjva, @Param("begin") int begin, @Param("end") int end);

    @Select("select * from FSP_NAVIGATION where ${ming} = '${zhi}'")
    List<FspNavigation> isSelectSome(@Param("ming") String ming, @Param("zhi") String zhi);

    @Select("${sql}")
    FspNavigation custom(@Param("sql") String sql);

    @Select("select count(*) from FSP_NAVIGATION where ${sqlName} = '${sqlVal}'")
    int getNum(@Param("sqlName") String sqlName, @Param("sqlVal") String sqlVal);

    @Select("${sql1}")
    List<FspNavigation> customs(@Param("sql1") String sql1);

    @Select("${sql2}")
    int customsNum(@Param("sql2") String sql2);

    @Select("select * from FSP_NAVIGATION where ${ming1} like '%${zhi1}%'")
    FspNavigation likeSeach(@Param("ming1") String ming1, @Param("zhi1") String zhi1);

    @Select("<script>SELECT B.*, CASE WHEN F_ROLE_CODE = '${F_ROLE_CODE}' THEN '0' WHEN F_ROLE_CODE != '${F_ROLE_CODE}' THEN '1' END isDLR FROM FSP_NAVIGATION B LEFT JOIN FSP_ROLE_NAVIGATION C ON B.uuid = C.F_NAVIGATION_ID WHERE 1=1 <if test=\"uuid != null and uuid != ''\"> AND uuid like '%${uuid}%'</if> <if test=\"F_NAVIG != null and F_NAVIG != ''\"> AND F_NAVIG like '%${F_NAVIG}%'</if></script>")
    List<Map<String, String>> getNavigationByRolecode(@Param("F_ROLE_CODE") String F_ROLE_CODE, @Param("uuid") String uuid, @Param("F_NAVIG") String F_NAVIG);

    @Select("SELECT B.* FROM FSP_NAVIGATION B LEFT JOIN FSP_ROLE_NAVIGATION C ON B.uuid = C.F_NAVIGATION_ID WHERE 1=1 AND C.F_ROLE_CODE='${F_ROLE_CODE}'")
    List<FspNavigation> getNavigationByRolecodeAll(@Param("F_ROLE_CODE") String F_ROLE_CODE);

}
